"""
从诗剧苦，筛选市盈率TTM 小于 13 的股票
"""

from easymoney.business.stock.webdriver import stock_info_service
from easymoney.framework.mysql.core.db_factory import InvestmentRecommendationEntity
from time import sleep

stock_codes = InvestmentRecommendationEntity.select()  # 股票代码列表

# 创建一个空列表来存储符合条件的股票代码和价格
cheap_stocks = []

# 遍历股票代码列表
for item in stock_codes:
    sleep(3)
    bi_dict = stock_info_service.get_stock_basic_info(item.stock_code)
    if 13 > bi_dict['市盈率TTM'] > 0:
        cheap_stocks.append(f"{bi_dict['股票代码']}, {bi_dict['股票简称']}, {bi_dict['市盈率TTM']}")

print(cheap_stocks)

